<?php
/**
 * 	印章管理
 *  author： chengda
 *  date  ： 2017-11-22
 */
namespace Admin\Controller;

class StampController extends AbstractController  {

	protected $From;

	public function _initialize(){
		$this->Form = D('stamp');
    }
    public function index(){
	    $res = $this->Form->MyshowList();
		$this->assign("list",$res['list']);
    	$this->assign("page",$res['page']);
        $this->display('ContractTemplate/Stamp/index');
    }

    public function select(){
	    $res = $this->Form->MyshowList();
		$this->assign("list",$res['list']);
    	$this->assign("page",$res['page']);
        $this->display('ContractTemplate/Stamp/select');
    }
    public function save($type = false, $id = 0){
    	if($type != false){
			if($type == "add"){
				$_POST['AddTime']=date('y-m-d h:i:s',time());
				if(!$this->Form->create()){
					exit($this->error($this->Form->getError()));
				}else{
					$result = $this->Form->add();
					if($result){
						$this->success('添加成功！',U('ContractTemplate/WaterMark/index'));
					}else{
						$this->error('添加错误！');
					}
				}
			}else if($type == "delete")
			{
				if(I('ID')){
					$result = $this->Form->where('ID='.I('ID'))->delete();
					if($result){
						$this->success('删除成功');
						exit();
					}
					$this->error('删除失败');
				}
			}
			}else{
			//$this->assign("data", $this->Form->GetCatalog());
			$this->display('ContractTemplate/Stamp/save');
		}
    }
    public function update(){
    			//$_POST['AddTime']=date('y-m-d h:i:s',time());
    			//var_dump($_POST);  exit();
				if(!$this->Form->create()){
					exit($this->error($this->Form->getError()));
				}else{
					$result = $this->Form->save();
					if($result){
						$this->success('修改成功！',U('ContractTemplate/Stamp/index'));
					}else{
						$this->error('修改错误！');
					}
				}
    }
    //预览章
    function edit(){
		if(I('ID')){
			$result = $this->Form->where('ID='.I('ID'))->find();
			if($result){
				$this->assign("data",$result);
       		 	$this->display('ContractTemplate/Stamp/veiw');
			}
		}
    }
}